//
//  ExamineeInfoModel.m
//  VideoExam
//
//  Created by apple on 2020/4/7.
//

#import "ExamineeInfoModel.h"

@implementation ExamineeInfoModel
- (instancetype)init
{
    self = [super init];
    if (self) {
//        _isSelected=NO;
       _phone = [UserModel get_userModel].phone;//默认显示登录手机号
        _is_select_China = YES;
    }
    return self;
}
- (void)setNationality:(NSString *)nationality {
    _nationality=nationality;
    if ([_nationality isEqualToString:@"中国"] || [_nationality isHelpful] == NO) {
        self.is_select_China = YES;
    } else  {
        self.is_select_China = NO;
    }
}
- (BOOL)can_submit_data {
    if ([self.phone isHelpful]==NO) {
        return NO;
    }
    if ([NSString verifyPhoneNumber:self.phone]==NO) {
        return NO;
    }
    
    if ([self.name isHelpful]==NO) {
        return NO;
    }
    
    if (self.name.length<=1  || self.name.length>11) {
        return NO;
    }
     
    if ([self.gender isHelpful]==NO) {
        return NO;
    }
    
    if ([self.nationality isHelpful]==NO) {
        return NO;
    }
    
    if ([self.nation isHelpful]==NO) {
           return NO;
    }
  
    if ([self.birthday isHelpful] == NO) {
        return NO;
    }
    if (self.is_select_China) {//中国身份证号
        if ([self.idCard cly_verifyIDCardString]==NO){
             return NO;
        }
    } else {
        if ([self.passport passport_validation]== NO) {//护照验证
            return NO;
        }
    }
    if (self.pictureImage==nil) {
        return NO;
    }
    return YES;
}

- (NSString *)get_gender_number {
    if ([self.gender isEqualToString:@"男"]) {
        return @"0";
    }
    return @"1";
}

/// 上传2寸照片
-(void)pictureImageSuccess:(ObjSuccess)successBlock error:(ErrorBlock)errorBlock {
    [NetWorkTools uploadImageWithImage:self.pictureImage success:^(NSString *urls) {
        NSLog(@"urls = %@",urls);
        self.pictureUrl = urls;
        if (successBlock) {
            successBlock(nil);
        }
    } failure:^(NSError *error) {
        NSLog(@"上传2寸照片 urls error");
        if (errorBlock) {
            errorBlock();
        }
    } progress:^(float progress) {
        NSLog(@"progress = %f",progress);
    }];
}

@end
